import { Prisma } from '@prisma/client';
import { IsDefined, IsNotEmptyObject } from 'class-validator';
import { BaseDto, BaseFindDto, BaseQueryDto } from './base.dto';
import { Transform } from 'class-transformer';

export class RightsCreateDto extends BaseDto<Prisma.RightsCreateInput> {}

export class RightsUpdateDto extends BaseDto<Prisma.RightsUpdateInput> {
  @IsDefined({ message: '条件必填' })
  @IsNotEmptyObject({ nullable: false }, { message: '条件参数必填' })
  where: Prisma.RightsWhereUniqueInput;
}

export class RightsFindDto extends BaseFindDto<
  Prisma.RightsWhereUniqueInput,
  Prisma.RightsSelect
> {}

export class RightsQueryDto extends BaseQueryDto<Prisma.RightsWhereUniqueInput> {}

export class RightsListDto extends BaseQueryDto<Prisma.RightsWhereUniqueInput> {}

export class RightsInvoiceQueryDto extends BaseQueryDto<
  Prisma.UserReceiveRightsWhereUniqueInput & {
    startTime?: string;
    endTime?: string;
    realname?: string;
    mobile?: string;
    assetId?: number;
  }
> {}

export class RightsInvoiceDispatchDto {
  @IsDefined({ message: 'ID必填' })
  @Transform(({ value }) => Number(value))
  id: number;

  @IsDefined({ message: '发货单号必填' })
  no: string;
}
